package cn.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @author m on 2023/1/28
 * Description:
 */
@Entity
@Getter
@Setter
public class Comment extends BaseEntity {

    private Integer pid = 0;

    private String content;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @JsonIgnore
    private User user;

    @OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
    private List<Comment> replyComment;

    @ManyToOne()
    @JsonIgnore
    private Article article;



    public Comment(){}

    public Comment(String content, Date createTime, User user, Article article) {
        this.content = content;
        this.createTime = createTime;
        this.user = user;
        this.article = article;
    }

    public Comment(Integer pid, String content, Date createTime, User user, Article article) {
        this.pid = pid;
        this.content = content;
        this.createTime = createTime;
        this.user = user;
        this.article = article;
    }


}
